home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 2002 Tom Parker (tom@carrott.org),
- Matthias Münch (matthias@amigaworld.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- In addition, as a special exception, Tom Parker and Matthias Münch give
- permission to link the code of this program with a TCP stack of your
- choice, any official MUI libraries or classes and any custom MUI classes
- that should be necessary for the operation of this program. This
- exception also gives you permission to distribute linked combinations
- including this software with any of the before-mentioned libraries and
- classes. You must obey the GNU General Public License in all respects for
- all of the code used other than that provided by the before-mentioned
- libraries and classes. As part of this exception you are obliged to
- follow the license terms of the before-mentioned libraries, this license
- does not compel you to follow those terms, but if you do not then you may
- not link with those libraries. If you modify this file, you may extend
- this exception to your version of the file, but you are not obligated to
- do so. If you do not wish to do so, delete this exception statement from
- your version.
- */
- /*
- ** utility functions
- */
-
- #include "common.h"
- #include <proto/openurl.h>
-
- struct Library *OpenURLBase;
-
-
- listitem *list_append(list **lis, void *data)
- {
- listitem *li;
-
- if(!*lis)
- {
- *lis = malloc(sizeof(list));
- if(!*lis) return(NULL);
- memset(*lis, 0, sizeof(list));
- }
-
- li = (listitem *)data;
- li->next = NULL;
- li->prev = (*lis)->last;
- if(!(*lis)->first) (*lis)->first = li;
- if((*lis)->last) (*lis)->last->next = li;
- (*lis)->last = li;
- (*lis)->count++;
-
- return li;
- }
-
-
- listitem *list_prepend(list **lis, void *data)
- {
- listitem *li;
-
- if(!*lis)
- {
- *lis = malloc(sizeof(list));
- if(!*lis) return(NULL);
- memset(*lis, 0, sizeof(list));
- }
-
- li = (listitem *)data;
- li->next = (*lis)->first;
- li->prev = NULL;
- if((*lis)->first) (*lis)->first->prev = li;
- (*lis)->first = li;
- if(!(*lis)->last) (*lis)->last = li;
- (*lis)->count++;
-
- return li;
- }
-
-
- void list_remove(list **lis, void *data)
- {
- listitem *li = (listitem *)data;
-
- if((*lis)->first == li) (*lis)->first = li->next;
- if((*lis)->last == li) (*lis)->last = li->prev;
- if(li->prev) li->prev->next = li->next;
- if(li->next) li->next->prev = li->prev;
- (*lis)->count--;
- }
-
-
- void list_remove_all(list **lis)
- {
- free(*lis);
- *lis = NULL;
- }
-
-
- char *my_printf(char *fmt, ...)
- {
- va_list ap;
- char *ret;
-
- va_start(ap, fmt);
- ret = my_vprintf(fmt, ap);
- va_end(ap);
-
- return ret;
- }
-
-
- char *my_vprintf(char *fmt, va_list ap)
- {
- static char buf[2048];
-
- vsprintf(buf, fmt, ap);
-
- return buf;
- }
-
-
- void open_url(char *url)
- {
- OpenURLBase = OpenLibrary("openurl.library",1);
- if(OpenURLBase)
- {
- URL_Open(url, TAG_DONE);
- CloseLibrary(OpenURLBase);
- }
- }
-